//
//  BuyDetailCell.m
//  体育商城
//
//  Created by  on 2022/9/23.
//

#import "BuyDetailCell.h"
@interface BuyDetailCell()
@property (strong, nonatomic) IBOutlet UILabel *title;
@property (strong, nonatomic) IBOutlet UILabel *detail;
@property (strong, nonatomic) IBOutlet UIView *bgView;
@property (strong, nonatomic) IBOutlet UILabel *content;
@property (strong, nonatomic) IBOutlet UIImageView *img;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *bgViewH;
@property(nonatomic, strong)WebView *webview;
@end
@implementation BuyDetailCell
- (void)awakeFromNib{
    [super awakeFromNib];
    [self bringSubviewToFront:self.webview];
}
- (WebView*)webview{
    if (!_webview) {
        _webview = [WebView new];
        _webview.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:_webview];
        NSLayoutConstraint *top = [_webview a1:NSLayoutAttributeTop e:NSLayoutRelationEqual t:self.bgView a2:NSLayoutAttributeBottom c:0];
        NSLayoutConstraint *left = [_webview a1:NSLayoutAttributeLeft e:NSLayoutRelationEqual t:self a2:NSLayoutAttributeLeft c:0];
        NSLayoutConstraint *right = [_webview a1:NSLayoutAttributeRight e:NSLayoutRelationEqual t:self a2:NSLayoutAttributeRight c:0];
        NSLayoutConstraint *bottom = [_webview a1:NSLayoutAttributeBottom e:NSLayoutRelationEqual t:self a2:NSLayoutAttributeBottom c:0];
        [self addConstraints:@[top,left,right,bottom]];
    }
    return _webview;
}

- (void)setModel:(Goods *)model{
    if (_model != model) {
        _model = model;
        self.content.text = [NSString stringWithFormat:@"%@ %@",model.name,model.shortDescription];
        [self.webview show:model.URL];
    }
}
@end
